/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Views.GestionRestaurateur;

import Model.Expertise;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.EventObject;
import javax.swing.AbstractCellEditor;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.event.CellEditorListener;
import javax.swing.table.TableCellEditor;

/**
 *
 * @author ibrahim
 */
public class ExpertiseEditor extends AbstractCellEditor implements TableCellEditor {
    
    private JComboBox combo;
    
    public ExpertiseEditor(){
       this.combo = new JComboBox(Expertise.values());
    }

    @Override
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
        combo.setSelectedItem(value);
        combo.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                fireEditingStopped();
            }
        });
        return combo;
    }

    @Override
    public Object getCellEditorValue() {
        return combo.getSelectedItem();
    }

    @Override
    public boolean isCellEditable(EventObject anEvent) {
        return true;
    }

   

   

    
    
}
